#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright (c) 2021 DilOS
#

PROG= genmsg

C_OBJS= main.o util.o

CMDDIR=	$(SRC)/cmd/genmsg
OBJS = $(C_OBJS) genmsg.tab.o genmsg.yy.o
SRCS = $(C_OBJS:%.o=$(CMDDIR)/%.c) genmsg.tab.c genmsg.yy.c

include ../Makefile.tools

CPPFLAGS = -I$(CMDDIR)

#LDLIBS += 
CFLAGS +=	$(CCVERBOSE)

CERRWARN +=	-_gcc=-Wno-unused-label
CERRWARN +=	-_gcc=-Wno-parentheses
CERRWARN +=	-_gcc=-Wno-unused-variable

.KEEP_STATE:

all: $(PROG) 

install: all .WAIT $(ROOTONBLDPROG)

$(PROG): $(OBJS)
	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
	$(POST_PROCESS)

%.o:	$(CMDDIR)/%.c
	$(COMPILE.c) -o $@ $<

genmsg.tab.h: genmsg.tab.c

$(CMDDIR)/genmsg.l: genmsg.tab.h

genmsg.yy.c: $(CMDDIR)/genmsg.l
	$(FLEX) -o genmsg.yy.c $(CMDDIR)/genmsg.l

genmsg.tab.c: $(CMDDIR)/genmsg.y
	$(BISON) -d -o genmsg.tab.c $(CMDDIR)/genmsg.y

$(OBJS): genmsg.tab.h

.y.c .NOINFER:

clean:
	$(RM) $(OBJS) genmsg.tab.* $(CMDDIR)/genmsg.tab.* genmsg.yy.c  $(CMDDIR)/genmsg.yy.c

include ../Makefile.targ
include $(SRC)/Makefile.master.64
